#include "widget.h"
#include "ui_widget.h"

#include <QIcon>
#include <QRect>
#include <QRadioButton>
#include <QDebug>
#include <QButtonGroup>

Widget::~Widget()
{
    delete ui;
}

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

}

//Widget::Widget(QWidget *parent)
//    : QWidget(parent)
//    , ui(new Ui::Widget)
//{
//    ui->setupUi(this);
//    QButtonGroup* group1 = new QButtonGroup(this);
//    QButtonGroup* group2 = new QButtonGroup(this);
//    QButtonGroup* group3 = new QButtonGroup(this);

//    group1->addButton(ui->radioButton);
//    group1->addButton(ui->radioButton_2);
//    group1->addButton(ui->radioButton_3);

//    group2->addButton(ui->radioButton_4);
//    group2->addButton(ui->radioButton_5);
//    group2->addButton(ui->radioButton_6);

//    group3->addButton(ui->radioButton_7);
//    group3->addButton(ui->radioButton_8);
//}

//Widget::Widget(QWidget *parent)
//    : QWidget(parent)
//    , ui(new Ui::Widget)
//{
//    ui->setupUi(this);
////    ui->radioButton_female->setChecked(true);
////    ui->label->setText("你选择的性别为：" + QString(ui->radioButton_female->text()));

////    //ui->radioButton_other->setCheckable(false); //不可选,但是点击后label会显示
////    ui->radioButton_other->setEnabled(false);   //直接设置为不可用
//}

//Widget::Widget(QWidget *parent)
//    : QWidget(parent)
//    , ui(new Ui::Widget)
//{
//    ui->setupUi(this);

//    //设置图标,删除文字
//    ui->pushButton_car->setIcon(QIcon(":/image/car.png"));
//    ui->pushButton_up->setIcon(QIcon(":/image/up.png"));
//    ui->pushButton_down->setIcon(QIcon(":/image/down.png"));
//    ui->pushButton_left->setIcon(QIcon(":/image/left.png"));
//    ui->pushButton_right->setIcon(QIcon(":/image/right.png"));

//    //调整图标大小
//    ui->pushButton_car->setIconSize(QSize(ui->pushButton_car->width(),ui->pushButton_car->height()));
//    ui->pushButton_left->setIconSize(QSize(QSize(ui->pushButton_left->width()-5,ui->pushButton_left->height()-5)));

//    //设置快捷键
//    //ui->pushButton_up->setShortcut(QKeySequence(Qt::Key_W));  //也可设置成这样
//    ui->pushButton_up->setShortcut(QKeySequence("w"));
//    ui->pushButton_down->setShortcut(QKeySequence("s"));
//    ui->pushButton_left->setShortcut(QKeySequence("a"));
//    ui->pushButton_right->setShortcut(QKeySequence("d"));

//    //设置重复触发
//    ui->pushButton_up->setAutoRepeat(true);
//    ui->pushButton_down->setAutoRepeat(true);
//    ui->pushButton_left->setAutoRepeat(true);
//    ui->pushButton_right->setAutoRepeat(true);
//}


//void Widget::on_pushButton_up_clicked()
//{
//    QRect rect = ui->pushButton_car->geometry();
//    ui->pushButton_car->setGeometry(rect.x(),rect.y()-5,rect.width(),rect.height());
//}

//void Widget::on_pushButton_down_clicked()
//{
//    QRect rect = ui->pushButton_car->geometry();
//    ui->pushButton_car->setGeometry(rect.x(),rect.y()+5,rect.width(),rect.height());
//}

//void Widget::on_pushButton_left_clicked()
//{
//    QRect rect = ui->pushButton_car->geometry();
//    ui->pushButton_car->setGeometry(rect.x()-5,rect.y(),rect.width(),rect.height());
//}

//void Widget::on_pushButton_right_clicked()
//{
//    QRect rect = ui->pushButton_car->geometry();
//    ui->pushButton_car->setGeometry(rect.x()+5,rect.y(),rect.width(),rect.height());
//}

//void Widget::on_radioButton_male_clicked()
//{
//    ui->label->setText("你选择的性别为：" + QString(ui->radioButton_male->text()));
//}

//void Widget::on_radioButton_female_clicked()
//{
//    ui->label->setText("你选择的性别为：" + QString(ui->radioButton_female->text()));
//}

//void Widget::on_radioButton_other_clicked()
//{
//    ui->label->setText("你选择的性别为：" + QString(ui->radioButton_other->text()));
//}

//void Widget::on_radioButton_male_clicked(bool checked)
//{
//    qDebug() << "on_radioButton_male_clicked(bool checked)";
//    qDebug() << checked;
//    if(checked)
//    {
//        ui->radioButton_male->setEnabled(false);
//    }
//}

//void Widget::on_radioButton_clicked(bool checked)
//{
//    qDebug() << "clicked:" << checked;  //不改变状态，“点击就送”
//}

//void Widget::on_radioButton_2_pressed()
//{
//    qDebug() << "pressed";      //按下触发
//}

//void Widget::on_radioButton_3_released()
//{
//    qDebug() << "released";     //抬起触发
//}

//void Widget::on_radioButton_4_toggled(bool checked)
//{
//    qDebug() << "toggled:" << checked;  //按钮的状态改变，触发
//}

void Widget::on_pushButton_clicked()
{
    QString ret = "你今天的安排是：";
    if(ui->checkBox_eat->isChecked())
        ret += ui->checkBox_eat->text() + " ";
    if(ui->checkBox_sleep->isChecked())
        ret += ui->checkBox_sleep->text()+ " ";
    if(ui->checkBox_play->isChecked())
        ret += ui->checkBox_play->text();

    ui->label->setText(ret);
}





